/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ODHeroes
 */
@Entity
@Table(name = "product_categories")
@NamedQueries({
    @NamedQuery(name = "ProductCategories.findAll", query = "SELECT p FROM ProductCategories p"),
    @NamedQuery(name = "ProductCategories.findByCategoryId", query = "SELECT p FROM ProductCategories p WHERE p.categoryId = :categoryId"),
    @NamedQuery(name = "ProductCategories.findByCode", query = "SELECT p FROM ProductCategories p WHERE p.code = :code"),
    @NamedQuery(name = "ProductCategories.findByCreatedAt", query = "SELECT p FROM ProductCategories p WHERE p.createdAt = :createdAt"),
    @NamedQuery(name = "ProductCategories.findByProductCategories", query = "SELECT p FROM ProductCategories p WHERE p.productCategories = :productCategories"),
    @NamedQuery(name = "ProductCategories.findByName", query = "SELECT p FROM ProductCategories p WHERE p.name = :name"),
    @NamedQuery(name = "ProductCategories.findByUpdatedAt", query = "SELECT p FROM ProductCategories p WHERE p.updatedAt = :updatedAt")})
public class ProductCategories implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "category_id")
    private BigDecimal categoryId;
    @Size(max = 256)
    @Column(name = "code")
    private String code;
    @Column(name = "created_at")
    @Temporal(TemporalType.DATE)
    private Date createdAt;
    @Column(name = "product_categories")
    private BigInteger productCategories;
    @Size(max = 256)
    @Column(name = "name")
    private String name;
    @Column(name = "updated_at")
    @Temporal(TemporalType.DATE)
    private Date updatedAt;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "categoryId")
    private Collection<Products> productsCollection;

    public ProductCategories() {
    }

    public ProductCategories(BigDecimal categoryId) {
        this.categoryId = categoryId;
    }

    public BigDecimal getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(BigDecimal categoryId) {
        this.categoryId = categoryId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public BigInteger getProductCategories() {
        return productCategories;
    }

    public void setProductCategories(BigInteger productCategories) {
        this.productCategories = productCategories;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Collection<Products> getProductsCollection() {
        return productsCollection;
    }

    public void setProductsCollection(Collection<Products> productsCollection) {
        this.productsCollection = productsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (categoryId != null ? categoryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductCategories)) {
            return false;
        }
        ProductCategories other = (ProductCategories) object;
        if ((this.categoryId == null && other.categoryId != null) || (this.categoryId != null && !this.categoryId.equals(other.categoryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.ProductCategories[ categoryId=" + categoryId + " ]";
    }
    
}
